package org.work;

import java.sql.Connection;
import java.sql.DriverManager;
import java.sql.PreparedStatement;

import org.model.Xsb;

public class DBConn {
    Connection conn;
    PreparedStatement pstmt;
    
    public DBConn(){
    	try {
    		Class.forName("com.microsoft.mysql.Driver");
    		conn=DriverManager.getConnection("jdbc:mysql://localhost:3306/mysql",
    				"root","123456");
    		
			
		} catch (Exception e) {
			e.printStackTrace();
		}
    }
    
    public boolean save(Xsb xs){
    	try{
    		pstmt=conn.prepareStatement("insert into XSB values(?,?,?,?,?,?)");
    		pstmt.setString(1, xs.getXh());
    		pstmt.setString(2,xs.getXm());
    		pstmt.setByte(3, xs.getXb());
    		pstmt.setString(4, xs.getZy());
    		pstmt.setDate(5, xs.getCssj());
    		pstmt.setString(6, xs.getBz());
    		pstmt.executeUpdate();
    	}catch (Exception e) {
			e.printStackTrace();
			return false;
		}
    	return true;
    }
    
}
